#coding=utf-8

import numpy as np

def dJ_debug(J, theta, X_b, y, epsilon = 0.01):

	res = np.empty(len(theta))

	for i in range(len(theta)):
		theta_1 = theta.copy()
		theta_1[i] += epsilon
		theta_2 = theta.copy()
		theta_2[i] -= epsilon

		res[i] = (J(theta_1, X_b, y) - J(theta_2, X_b, y)) / (2 * epsilon)

	return res